package be.android.forap.gui;

import be.android.forap.R;
import android.app.Activity;
import android.database.Cursor;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.provider.ContactsContract.Data;
import android.widget.TextView;

public class ProfileActivity extends Activity {
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.profile);	
		
		if (getIntent().getData() != null) {
			Cursor cursor = managedQuery(getIntent().getData(), null, null, null, null);
			if (cursor.moveToNext()) {
				

				String displayName = cursor.getString(cursor.getColumnIndex(Data.DISPLAY_NAME));
				((TextView) findViewById(R.id.profile_textview_title)).setText(displayName);
				String pkey = cursor.getString(cursor.getColumnIndex(ContactsContract.Data.DATA4));
				((TextView) findViewById(R.id.profile_textview_public_key)).setText(pkey);
				String accountname = cursor.getString(cursor.getColumnIndex(ContactsContract.RawContacts.ACCOUNT_NAME));
				((TextView) findViewById(R.id.profile_textview_accountname)).setText(accountname);
				String accounttype = cursor.getString(cursor.getColumnIndex(ContactsContract.RawContacts.ACCOUNT_TYPE));
				((TextView) findViewById(R.id.profile_textview_accounttype)).setText(accounttype);
				String globalid = cursor.getString(cursor.getColumnIndex(ContactsContract.Data.DATA1));
				((TextView) findViewById(R.id.profile_textview_globalid)).setText(globalid);
				String contenttype = cursor.getString(cursor.getColumnIndex(Data.MIMETYPE));
				((TextView) findViewById(R.id.profile_textview_contenttype)).setText(contenttype);
				String dirty = cursor.getString(cursor.getColumnIndex(ContactsContract.RawContacts.DIRTY));
				((TextView) findViewById(R.id.profile_textview_dirty)).setText(dirty);
			}
		} else {
			// How did we get here without data?
			finish();
		}
	}
}
